#define _GNU_SOURCE     // 使用unistd扩展 
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>

void *thread1_func(void *arg)
{
    printf("线程1:(%d)开始执行...\n",gettid());
    return NULL;
}
void *thread2_func(void *arg)
{
    printf("线程2:(%d)开始执行...\n",gettid());
    return NULL;
}

int main()
{
    printf("主线程(%d)开始执行...\n",gettid());
    // 创建一个线程
    pthread_t tid1,tid2;
    pthread_create(&tid1,NULL,thread1_func,NULL);
    pthread_create(&tid2,NULL,thread2_func,NULL);

    // 等待线程执行完毕
    pthread_join(tid1,NULL);
    pthread_join(tid2,NULL);
    printf("主线程(%d)执行完毕...\n",gettid());
    return 0; 
}